package com.example.b_308.myapplication.comment.view.page;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * Created by B-308 on 2017/11/17.
 */
public class WorkViewPager extends ViewPager {
    private boolean isEnableTouchEvent = false;

    public WorkViewPager(Context context) {
        super(context);
    }

    public WorkViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (this.isEnableTouchEvent) {
            return super.onTouchEvent(event);
        }
        return false;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        if (this.isEnableTouchEvent) {
            return super.onInterceptTouchEvent(event);
        }
        return false;
    }

    public void setSwipingEnabled(boolean enabled) {
        this.isEnableTouchEvent = enabled;
    }

}
